<?php
/**
 * Created by PhpStorm.
 * User: zhang-hong
 * Date: 2017/4/25
 * Time: 14:51
 */
class GetdingshixunshidatajsonController extends Yaf_Controller_Abstract
{

    public function indexAction()
    {
        //获取参数
        $request = $this->getRequest();
        $yiyuan_id = $request->getPost('yiyuan_id',0);
        $user_department = $request->getPost('user_department','');
        $zhuyuan_id = $request->getPost('zhuyuan_id','');
        $modify_time = $request->getPost('modify_time','');
        $json_data_str = $request->getPost('data','');
        $compression_http_data = $request->getPost('compression_http_data','off');
        $hulijibie = $request->getPost('hulijibie','');
        if(empty($user_department))
        {
            Utility::apiJsonError(30010, '科室不能为空');
        }

        if(empty($hulijibie))
        {
            Utility::apiJsonError(30010, '护理级别不能为空');
        }
        // 解压缩数据
        $json_data = json_decode(Utility::uncompress($json_data_str, $compression_http_data));
        $model = new DingshiXunChaModel();
        $field_arr = $model->_field_arr;
        $data = $model->getDingshiXuchaData($zhuyuan_id,$user_department,$json_data,$hulijibie,$modify_time);

        $async_result = Utility::formatToSqlStrExtends($data, 'dingshi_xunshi_zhixing', 'update_sql', $field_arr);

        $result["response_state"] = "true";
        $result["response_info"] = "数据同步成功:)";
        if(empty($async_result)){
            $result["update_sql"] = array();
        }else{
            $result["update_sql"] = $async_result;
        }
        $result["error"] = 200;
        $result["msg"] = "";
        Utility::apiJsonResultExtends($result);
    }
}